import numpy as np
import imgaug.augmenters as iaa
import glob
import cv2
import imgaug as ia

seq = iaa.Sequential([
        # iaa.OneOf([
                # iaa.Affine(translate_percent={"x": (-0.2, 0.2), "y": (-0.2, 0.2)}, cval=255, name="Rotate"),
                # iaa.Affine(rotate=(-15, 15), cval=255, name="Rotate"),
                # iaa.Affine(scale=1.3, cval=255, name="Scale"),
                # iaa.Affine(shear=(-16, 16), cval=255, name="Sheer")
                   # ]),

                   iaa.Multiply(0.25, name="Multiply"),
    # iaa.Crop(px=(90, 800), keep_size=True),
    # iaa.Fliplr(1),
    # iaa.GaussianBlur(sigma=3.0)
    # iaa.MotionBlur( k=4)
    # iaa.AverageBlur(3)
    # iaa.BilateralBlur(10)
    # iaa.MedianBlur(2 )
    # iaa.Affine(
            #scale={"x": (0.1, 0.5), "y": (0.1, 0.5)}, # scale images to 80-120% of their size, individually per axis
            # translate_percent={"x": (-0.9, 0.9), "y": (-0.9, 0.9)}, # translate by -20 to +20 percent (per axis)
            # rotate=(-45, 45), # rotate by -45 to +45 degrees
            # shear=(-90, 90), # shear by -16 to +16 degrees
            #order=[0, 1], # use nearest neighbour or bilinear interpolation (fast)
            # cval=255, # if mode is constant, use a cval between 0 and 255
            #mode=ia.ALL # use any of scikit-image's warping modes (see 2nd image from the top for examples)
        # )
])
while(1):
    for imgpath in glob.glob("sample/pictures/*"):
        print(imgpath)
        img = cv2.imread(imgpath)
        img = cv2.resize(img, (480,480))
        img = np.expand_dims(img, 0)

        images_aug = seq(images=img)  # done by the library

        cv2.imshow("img", cv2.resize(images_aug[0], (512, 512)) )
        cv2.waitKey(0)
